#ifndef CFA_H
#define CFA_H
#include "typedef.h"
#include <set>
#include <map>
#include <string.h>
using namespace std;

//three types nodes
struct Node{
    vector<Node*> prev;//Prev
    virtual ~Node(){ }
    virtual bool operator==(Node &other)=0;//not yet implemented
};
/*
x = e | skip | x = id(e1, e2, ...) | return x | L: s | goto L | break | continue
*/
struct UniNode: Node{
    Expr* e1;				//for assignment x:=e or return x, x is stored in expression e1
    Expr* e2;				//for assignment x:=e only, e is stored in expression e2
    char statement[256];	//original program statement, for print only
    //function call
    char name[256];			//id of the function
    vector<Expr*> actualpara;
    Node *next;
    bool operator==(Node &other);
    StmtType st;
};
/*
while b do  s | if b then s else s
*/
struct BinNode: Node{
    Prop *p;//guard
    Node *_true, *_false;	//if guard is true, it will go to next1, otherwise next2
    char statement[256];
    bool operator==(Node &other);
};

struct BadNode: Node{
    bool operator==(Node &other);
};

//CFA
class CFA{
	private:
		char id[256];
		vector<LValExpr*> formal_parameter;

    public:
        Node* GetInitNode(){ return initNode; } 
        char* GetId(){ return id; }
        vector<LValExpr*> GetFormPara(){ return formal_parameter; }
        void AddFormPara(LValExpr* v){ formal_parameter.push_back(v); }		//
        //void PrintCFA();
        //void PrintBackCFA();
        //void CFA2Dot(char*,int);//output graph to file
        //void PrintNode(Node*);
};
#endif
